package tongwentongshu.com.app;

import android.content.Intent;
import android.os.Handler;

import tongwentongshu.com.app.activity.BaseActivity;
import tongwentongshu.com.app.contract.CallBackColonyContract;
import tongwentongshu.com.app.utils.SpUtils;

import static tongwentongshu.com.app.App.EXTRA_BUNDLE;

public class WelcomeActivity extends BaseActivity {


    @Override
    protected int getLayoutResourceId() {
        return R.layout.activity_welcome;
    }

    @Override
    protected int getTitleId() {
        return R.string.app_name;
    }

    @Override
    protected void initView() {
        setPermissonCallBack(new CallBackColonyContract.OnCheckPermissions() {
            @Override
            public void check() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        String first = SpUtils.getString(mContext, "first", "-1");
                        if ("-1".equals(first)) {
                            SpUtils.setString(mContext, "first", "1");
                            startActivity(BootPageActivity.class);
                        } else {
                            Intent intent = new Intent(WelcomeActivity.this, MapMainActivity.class);
                            if (getIntent().getBundleExtra(EXTRA_BUNDLE) != null) {
                                intent.putExtra(EXTRA_BUNDLE,
                                        getIntent().getBundleExtra(EXTRA_BUNDLE));
                            }
                            startActivity(intent);
                        }
                        finish();

                    }
                }, 2000);
            }
        });

    }

    @Override
    protected void initData() {

    }
}
